package guiclient;

import java.awt.Color;

public class GUIError extends javax.swing.JFrame {

    private Color colorBackgroud = new Color(240, 240, 240);

    public GUIError() {
        initComponents();
        getContentPane().setBackground(colorBackgroud);
    }

    public void setErrorMessage(String message) {
        errorDescriptionJLabel.setText(message);
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        errorIconJLabel = new javax.swing.JLabel();
        errorDescriptionJLabel = new javax.swing.JLabel();
        errorMessageJLabel = new javax.swing.JLabel();
        errorAcceptJButton = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Ha ocurrido un error...");
        setLocationByPlatform(true);
        setResizable(false);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                formWindowClosing(evt);
            }
            public void windowClosed(java.awt.event.WindowEvent evt) {
                formWindowClosed(evt);
            }
        });

        errorIconJLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        errorIconJLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/guiclient/images/error.png"))); // NOI18N

        errorDescriptionJLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);

        errorMessageJLabel.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N
        errorMessageJLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        errorMessageJLabel.setText("Lo sentimos... Ha ocurrido el siguiente error:");

        errorAcceptJButton.setText("Aceptar");
        errorAcceptJButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                errorAcceptJButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(errorDescriptionJLabel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(errorIconJLabel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(errorMessageJLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 311, Short.MAX_VALUE)
                    .addComponent(errorAcceptJButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(errorIconJLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(errorMessageJLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(errorDescriptionJLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(errorAcceptJButton)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void errorAcceptJButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_errorAcceptJButtonActionPerformed
        setVisible(false);
    }//GEN-LAST:event_errorAcceptJButtonActionPerformed

    private void formWindowClosed(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosed
    }//GEN-LAST:event_formWindowClosed

    private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
        setVisible(false);
    }//GEN-LAST:event_formWindowClosing

    public static void main(String args[]) {
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException | InstantiationException | IllegalAccessException |
                javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(GUIError.class.getName()).log(java.util.logging.Level.SEVERE,
                    "Fallo al iniciar la ventana de error", ex);
        }

        java.awt.EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {
                new GUIError().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton errorAcceptJButton;
    private javax.swing.JLabel errorDescriptionJLabel;
    private javax.swing.JLabel errorIconJLabel;
    private javax.swing.JLabel errorMessageJLabel;
    // End of variables declaration//GEN-END:variables
}
